package com.lhy.ltss.util;

import lombok.NonNull;
import org.springframework.util.DigestUtils;

/**
 * @description:
 * @author: 李汇远
 */
public class Password {

    /**
     * 加密的盐
     */
    private static final String SALT = "guozhi97";

    /**
     * 获取加密后的密码
     * @param password
     * @return
     */
    public static String getEncryption(@NonNull String password){
        return new String(DigestUtils.md5Digest((password + SALT).getBytes()));
    }

    /**
     * 校验密码
     * @param dbPassword
     * @param password
     * @return
     */
    public static boolean check(@NonNull String dbPassword, @NonNull String password){
        String encryption = getEncryption(password);
        return encryption.equals(dbPassword);
    }
}
